package com.lx.pc.service.supplycategory.impl;

import java.math.BigInteger;
import java.util.List;

import org.springframework.stereotype.Service;

import com.lx.pc.domain.entity.supplycategory.SupplyCategoryEntity;
import com.lx.pc.domain.vo.supplycategory.SupplyCategoryVo;
import com.lx.pc.mybatis.repository.supplycategory.SupplyCategoryRepository;
import com.lx.pc.service.AbstractService;
import com.lx.pc.service.supplycategory.ISupplyCategoryService;
import com.lx.pc.utils.OmsPage;

@Service("supplyCategoryService")
public class SupplyCategoryServiceImpl extends AbstractService<SupplyCategoryEntity, SupplyCategoryVo, BigInteger, SupplyCategoryRepository> implements ISupplyCategoryService{

	@Override
	public int findByCategoryCount(SupplyCategoryVo category) {
		return repository.findByCategoryCount(category);
	}

	@Override
	public OmsPage<SupplyCategoryVo> findByCategory(SupplyCategoryVo category, Integer page, Integer size) {
		OmsPage<SupplyCategoryVo> pages = new OmsPage<SupplyCategoryVo>();
		pages.setTotal(repository.findByCategoryCount(category));
		List<SupplyCategoryEntity> list = repository.findByCategory(category,page = (page - 1) * size,size);
		pages.setResult(etoV(list));
		return pages;
	}

	@Override
	public List<SupplyCategoryVo> findByCategoryList(SupplyCategoryVo category) {
		
		return etoV(repository.findByCategoryList(category));
	}

}
